package com.heima.admin.controller;

import com.heima.admin.service.AdChannelService;
import com.heima.model.admin.dtos.ChannelDTO;
import com.heima.model.admin.pojos.AdChannel;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelController {
    @Autowired
    private AdChannelService adChannelService;
    @PostMapping("/list")
    public ResponseResult PageSelect(@RequestBody ChannelDTO channelDTO){
        return adChannelService.PageSelect(channelDTO);
    }
    @PostMapping("/save")
    public ResponseResult insertChannel(@RequestBody AdChannel channel )
    {
        return adChannelService.insertChannel(channel);
    }
    @ApiOperation("频道修改")
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody AdChannel channel ){
        return adChannelService.updateChannel(channel);
    }
    @GetMapping("/del/{id}")
    public ResponseResult deleteChannel(@PathVariable("id") Integer id){
        return adChannelService.deleteById(id);
    }
    @ApiOperation("查询全部频道")
    @GetMapping("/channels")
    public ResponseResult findAll() {
        List<AdChannel> list = adChannelService.list();
        return ResponseResult.okResult(list);
    }
}
